import javax.swing.tree.TreeNode;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-05-05
 * Time: 16:13
 */
public class test4 {
    public int maxDepth(TreeNode root) {
        if(root==null){
            return 0;
        }else{
            // 往左边找
            int leftHeight = maxDepth(root.left);
            // 往右边找
            int rightHeight = maxDepth(root.right);
            return Math.max(leftHeight,rightHeight)+1;
        }
    }
}
